app.controller('RtShiftModalCtrl', function ($scope, $filter, $modalInstance, toaster, param) {

	$scope.submitting = false;
	$scope.param = param;
	if ($scope.param.data == null) {
		$scope.param.data = {};
	}
	$scope.timeRange = {};
	if ($scope.param.type == "update") {
		var day = $filter("date")($scope.param.data.departDay, "yyyy-MM-dd");
		var time = $filter("date")($scope.param.data.departTime, "HH:mm:ss");
		var date = $filter("date")(day + " " + time, "yyyy-MM-dd HH:mm:ss");
		$scope.timeRange.startTime = date;
	}

	$scope.ok = function () {
			if ($scope.timeRange.startTime) {
				var startTime = $filter("date")($scope.timeRange.startTime, "yyyy/MM/dd HH:mm:ss");
				var strs = startTime.split(" ");
				var day = new Date(strs[0]);
				var time = new Date(startTime);
				$scope.param.data.departDay = day;
				$scope.param.data.departTime = time;
			} else {
				toaster.pop('warning', '提示', '请选择日期！');
				return;
			}
			$modalInstance.close($scope.param);
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
		$scope.submitting = false;
	};
});